package com.atguigu.dga230301.governance.assess.spec;

import com.atguigu.dga230301.governance.assess.Assessor;
import com.atguigu.dga230301.governance.bean.AssessParam;
import com.atguigu.dga230301.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga230301.governance.bean.GovernanceMetric;
import com.atguigu.dga230301.meta.bean.TableMetaInfo;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component("TEC_OWNER")
public class TecOwnerAssess extends Assessor {

    @Override
    protected void assessor(GovernanceAssessDetail governanceAssessDetail, AssessParam assessParam) {

        TableMetaInfo tableMetaInfo = assessParam.getTableMetaInfo();
        GovernanceMetric governanceMetric = assessParam.getGovernanceMetric();
        //判断是否有技术负责人
        if (tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName()==null||tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName().length()<=0){
            //没有技术负责人的话给0分
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            governanceAssessDetail.setAssessProblem("没有技术负责人");
            String governanceUrl = governanceMetric.getGovernanceUrl();
            //设置 配置技术负责人路径
            String url = governanceUrl + tableMetaInfo.getId();
            governanceAssessDetail.setGovernanceUrl(url);
        }
    }
}
